package com.ocean4.progress_dialog;

import com.ocean4.socialmap.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.IBinder;
import android.provider.Settings;

public class AlertDialogManager extends Service {
	Context mcontext;

	public AlertDialogManager(Context mcontext) {
		super();
		this.mcontext = mcontext;
	}

	public void showAlertDialog(Context context, String title, String message,
			Boolean status) {
		AlertDialog alertDialog = new AlertDialog.Builder(context).create();

		// Setting Dialog Title
		alertDialog.setTitle(title);

		// Setting Dialog Message
		alertDialog.setMessage(message);

		if (status != null)
			// Setting alert dialog icon
		alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);

		// functions
		alertDialog.setButton(Dialog.BUTTON_NEGATIVE, "Exit", new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				
				dialog.dismiss();
				System.exit(0);
				
			}
		});

		alertDialog.setButton(Dialog.BUTTON_POSITIVE, "Menu Settings",
				new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						Intent intent = new Intent(
								Settings.ACTION_LOCATION_SOURCE_SETTINGS);
						mcontext.startActivity(intent);
					}
				});

		// Showing Alert Message
		alertDialog.show();
	}

	@Override
	public IBinder onBind(Intent intent) {

		return null;
	}
}
